{% extends "@XiaoZhu/base/frame.html.twig" %}

{% block content_header %}
    <div class="title-wrapper">
        <div class="container"><div class="container-inner">
                <h1><span>MEN</span> CATEGORY</h1>
                <em>Over 4000 Items are available here</em>
            </div></div>
    </div>
{% endblock %}

{% block content_main %}
    <div class="main">
        <div class="container">
            <ul class="breadcrumb">
                <li><a href="{{ path("shophome") }}">首页</a></li>
                <li class="active">产品列表</li>
            </ul>
            <!-- BEGIN SIDEBAR & CONTENT -->
            <div class="row margin-bottom-40">
                <!-- BEGIN SIDEBAR -->
                <div class="sidebar col-md-3 col-sm-5">
                    <ul class="list-group margin-bottom-25 sidebar-menu">
                        <li class="list-group-item clearfix {{app.request.get("category") is  defined and  app.request.get("category") ==  1  ? 'active' : "" }}"><a href="{{ path("listProduct") }}?category=1"><i class="fa fa-angle-right"></i> 全部饰品 </a></li>
                    {% for cat in CatTree %}
                        {% if cat.sons is not defined %}
                            <li class="list-group-item clearfix {{app.request.get("category") is  defined and  app.request.get("category") ==  cat.id  ? 'active' : "" }}"><a href="{{ path("listProduct") }}?category={{ cat.id }}"><i class="fa fa-angle-right"></i> {{ cat.name }}</a></li>
                            {% else %}
                            <li class="list-group-item clearfix dropdown {{app.request.get("category") is  defined and  app.request.get("category") ==  cat.id  ? 'active' : "" }}">
                                <a href="{{ path("listProduct") }}?category={{ cat.id }}" class="">
                                    <i class="fa fa-angle-right"></i>
                                    {{ cat.name }}
                                </a>
                                <ul class="dropdown-menu" style="display:block;">
                                {% for cat1 in cat.sons %}
                                    <li class="{{app.request.get("category") is  defined and  app.request.get("category") ==  cat1.id  ? 'active' : "" }}"><a href="{{ path("listProduct") }}?category={{ cat1.id }}"><i class="fa fa-angle-right"></i>{{ cat1.name }}</a></li>
                                {% endfor %}
                                </ul>
                            </li>
                        {% endif %}
                    {% endfor %}
                    </ul>

                    <div class="sidebar-filter margin-bottom-25">
                        {% for attr in attrAndValues %}
                            <h2 class="">{{ attr.name }}</h2>
                            <div class="checkbox-list margin-top-10" style="padding-bottom: 20px;">
                                <select class="form-control input-sm searchCond">
                                    <option value="" key="valId[{{ attr.values[0].attrId }}]">全部{{ attr.name }}</option>
                                    {% for val in attr.values %}
                                        <option {% if app.request.cookies.get("valId")[val.attrId] is defined and app.request.cookies.get("valId")[val.attrId] == val.id %} selected {% endif %} value="{{ val.id }}" key="valId[{{ val.attrId }}]">{{ val.attrVal }}</option>
                                    {% endfor %}
                                </select>
                            </div>
                        {% endfor %}
                        {#<h2>品牌</h2>#}
                        {#<div class="checkbox-list margin-top-10">#}
                            {#<select class="form-control input-sm searchCond">#}
                                {#<option value="">选择品牌</option>#}
                                {#<option value="&perPage=15">15</option>#}
                                {#<option value="&perPage=30">30</option>#}
                                {#<option value="&perPage=60">60</option>#}
                                {#<option value="&perPage=90">90</option>#}
                            {#</select>#}
                        {#</div>#}
                        {#<h3>Price</h3>#}
                        {#<p>#}
                            {#<label for="amount">Range:</label>#}
                            {#<input type="text" id="amount" style="border:0; color:#f6931f; font-weight:bold;">#}
                        {#</p>#}
                        {#<div id="slider-range" class="ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all" aria-disabled="false">#}
                            {#<div class="ui-slider-range ui-widget-header ui-corner-all" style="left: 10%; width: 40%;"></div>#}
                            {#<a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="left: 10%;"></a>#}
                            {#<a class="ui-slider-handle ui-state-default ui-corner-all" href="#" style="left: 50%;"></a>#}
                        {#</div>#}
                    </div>

                    <div class="sidebar-products clearfix">
                        <h2>热卖商品</h2>
                        {% for product in ProductHot %}
                            {% include("XiaoZhuBundle:inc:ProductListItemSidebar.html.twig") %}
                        {% endfor %}
                    </div>
                </div>
                <!-- END SIDEBAR -->
                <!-- BEGIN CONTENT -->
                <div class="col-md-9 col-sm-7">
                    <div class="row list-view-sorting clearfix">
                        <div class="col-md-2 col-sm-2 list-view">
                            <a href="#"><i class="fa fa-th-large"></i></a>
                            <a href="#"><i class="fa fa-th-list"></i></a>
                        </div>
                        <div class="col-md-10 col-sm-10">
                            <div class="pull-right">
                                <label class="control-label">每页显示:</label>
                                <select class="form-control input-sm searchCond" name="perPage">
                                    <option value="3" key="perPage"{% if app.request.cookies.get("perPage") is defined and app.request.cookies.get("perPage") == 3 %} selected {% endif %}>3</option>
                                    <option value="15" key="perPage"{% if app.request.cookies.get("perPage") is defined and app.request.cookies.get("perPage") == 15 %} selected {% endif %}>15</option>
                                    <option value="30" key="perPage"{% if app.request.cookies.get("perPage") is defined and app.request.cookies.get("perPage") == 30 %} selected {% endif %}>30</option>
                                    <option value="60" key="perPage"{% if app.request.cookies.get("perPage") is defined and app.request.cookies.get("perPage") == 60 %} selected {% endif %}>60</option>
                                    <option value="90" key="perPage"{% if app.request.cookies.get("perPage") is defined and app.request.cookies.get("perPage") == 90 %} selected {% endif %}>90</option>
                                </select>
                            </div>
                            <div class="pull-right">
                                <label class="control-label">排序:</label>
                                <select class="form-control input-sm searchCond" name="orderBy">
                                    <option value="" key="noOrderBy">默认</option>
                                    <option value="1" key="sell"{% if app.request.cookies.get("sell") is defined and app.request.cookies.get("sell") == 1 %} selected {% endif %}>销量由高到低</option>
                                    <option value="2" key="sell"{% if app.request.cookies.get("sell") is defined and app.request.cookies.get("sell") == 2 %} selected {% endif %}>销量由低到高</option>
                                    <option value="1" key="price"{% if app.request.cookies.get("price") is defined and app.request.cookies.get("price") == 1 %} selected {% endif %}>价格由高到低</option>
                                    <option value="2" key="price"{% if app.request.cookies.get("price") is defined and app.request.cookies.get("price") == 2 %} selected {% endif %}>价格由低到高</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <!-- BEGIN PRODUCT LIST -->
                    <div class="row product-list">
                        {% for product in products %}
                        <!-- PRODUCT ITEM START -->
                        <div class="col-md-4 col-sm-6 col-xs-12">
                            {% include("XiaoZhuBundle:inc:ProductListItemNew.html.twig") %}
                        </div>
                        <!-- PRODUCT ITEM END -->
                        {% endfor %}
                    </div>
                    <!-- END PRODUCT LIST -->
                    <!-- BEGIN PAGINATOR -->
                    <div class="row">
                        <div class="clear"></div>
                        <div class="btn-group">
                            <div class="btn dark">每页 {{ pagination.perPage }} 条 共 {{ pagination.total }} 条</div>
                        </div>
                        {{ pagination.page | raw}}
                        {#<div class="col-md-4 col-sm-4 items-info">Items 1 to 9 of 10 total</div>#}
                        {#<div class="col-md-8 col-sm-8">#}
                            {#<ul class="pagination pull-right">#}
                                {#<li><a href="#">«</a></li>#}
                                {#<li><a href="#">1</a></li>#}
                                {#<li><span>2</span></li>#}
                                {#<li><a href="#">3</a></li>#}
                                {#<li><a href="#">4</a></li>#}
                                {#<li><a href="#">5</a></li>#}
                                {#<li><a href="#">»</a></li>#}
                            {#</ul>#}
                        {#</div>#}
                    </div>
                    <!-- END PAGINATOR -->
                </div>
                <!-- END CONTENT -->
            </div>
            <!-- END SIDEBAR & CONTENT -->
        </div>
    </div>

{% endblock %}
{% block content_footer %}
    <script type="text/javascript" language="JavaScript">
        $(function () {
            $(".searchCond").change(function () {
                var val = $(this).val();
                var key = $(this).find("option:selected").attr("key");
                switch (key) {
                    case "sell":
                        $.removeCookie("price");
                        break;
                    case "price":
                        $.removeCookie("sell");
                        break;
                    case "noOrderBy":
                        $.removeCookie("sell");
                        $.removeCookie("price");
                        break;
                    default :

                }
                if (val && key != "noOrderBy") {$.cookie(key,val);}else{$.removeCookie(key);}
                location.href = location;
            });
        });
    </script>
    <style>.searchCond{}</style>
{% endblock %}

{% block product_pop_up %}
    {% set ProductPopUps = products %}
    {% include("XiaoZhuBundle:inc:ProductPopUps.html.twig") %}
{% endblock %}